﻿using QingZhouLinYe_Web.DbContext;
using QingZhouLinYe_Web.Models;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace QingZhouLinYe_Web.Ashxs
{
    /// <summary>
    /// SaveFangHuoDanWei 的摘要说明
    /// </summary>
    public class SaveFangHuoDanWei : IHttpHandler
    {
        private DbServices dbServices = new DbServices();
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            Random ran = new Random();
            List<FangHuoDanWei> fhdws = new List<FangHuoDanWei>();
            FangHuoDanWei fhdw0 = new FangHuoDanWei();
            fhdw0.CenterShape = new Location(BaseClass.RandomDouble(ran,118.33, 119.45), BaseClass.RandomDouble(ran,36.33, 36.45), BaseClass.RandomInt(ran,1,100));
            //fhdw0.BorderShape = new Polygon(BaseClass.RandomDouble(118.33, 119.45), BaseClass.RandomDouble(36.33, 36.45), 200);
            fhdw0.QuHuaId = 2;
            fhdw0.MingCheng = "防灭火巡查专业队";
            fhdw0.MapLevel = 9;
            fhdws.Add(fhdw0);
            FangHuoDanWei fhdw1 = new FangHuoDanWei();
            fhdw1.QuHuaId = 2;
            fhdw1.CenterShape = new Location(BaseClass.RandomDouble(ran,118.33, 119.45), BaseClass.RandomDouble(ran,36.33, 36.45), BaseClass.RandomInt(ran, 1, 100));
            //fhdw1.BorderShape = new Location(BaseClass.RandomDouble(118.33, 119.45), BaseClass.RandomDouble(36.33, 36.45), 200);
            fhdw1.MingCheng = "王坟镇";
            fhdw1.MapLevel = 10;
            fhdws.Add(fhdw1);
            foreach (var f in fhdws)
            {
                int i = dbServices.saveFangHuoDanWei(f);
                
                context.Response.Write(i + "数据添加成功！");
            }
        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}